package cn.anecansaitin.firecrafting.client.crafting;

import cn.anecansaitin.firecrafting.api.common.crafting.IFireRecipe;
import cn.anecansaitin.firecrafting.api.client.crafting.IJEIRecipeRender;
import cn.anecansaitin.firecrafting.common.crafting.FireFluidRecipe;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.fluids.FluidStack;
import oshi.util.tuples.Triplet;

import java.util.ArrayList;
import java.util.List;

public class FireFluidRecipeRender implements IJEIRecipeRender {
    //这个类只需要一个就可以了，因此将构造函数设为private并提供一个静态实现。
    public static final FireFluidRecipeRender INSTANCE = new FireFluidRecipeRender();

    private FireFluidRecipeRender() {}

    @Override
    public List<Triplet<FluidStack, Integer, Integer>> getResultFluidSlots(IFireRecipe recipe) {
        if (recipe instanceof FireFluidRecipe) {
            //返回配方的流体产物
            return List.of(new Triplet<>(((FireFluidRecipe) recipe).getOutputs(), 142, 35));
        }
        return new ArrayList<>();
    }

    @Override
    public void drawBeforeFire(IFireRecipe recipe, PoseStack stack, double mouseX, double mouseY) {
        if (recipe instanceof FireFluidRecipe) {
            //绘制流体名
            GuiComponent.drawCenteredString(stack, Minecraft.getInstance().font, new TextComponent(((FireFluidRecipe) recipe).getOutputs().getAmount() + " MB").withStyle(ChatFormatting.BLUE), 151, 55, 0x000000);
        }
    }
}
